package com.yuma.rabbitmq.springbootproductor.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.beans.JavaBean;

@Configuration
public class RabbitConfiguration {

    // 创建交换机
    @Bean
    public Exchange directExchange(){
        // Direct交换机
        return ExchangeBuilder.directExchange("java_direct").durable(true).build();
    }

    // 2.创建队列
    @Bean
    public Queue queue(){
        return QueueBuilder.durable("queue.jd").build();
    }

    // 3.创建绑定关系
    @Bean
    public Binding queueBinding() {
        return BindingBuilder.bind(queue()).to(directExchange()).with("jd").noargs();
    }
}
